//初始化
function init() {
    var target = document.getElementById('target');
    var tween = new TWEEN.Tween(target.dataset)
                .to({top: '+50', left: '-50'})
                .repeat(3)
                .easing(TWEEN.Easing.Exponential.In)
                .delay(500)
                .onUpdate(function(obj) {
                    var transform = `translate(${obj.left}px, ${obj.top}px)`;
                    target.style.transform = transform;
                })
                .start();
}

//动画函数
function animate() {
    var id = requestAnimationFrame(animate);
    var result = TWEEN.update();
    if(!result) cancelAnimationFrame(id);
}

init();
animate();